<template>
    <IDrawer v-model="defaultValue" :loading="loading" :width="400" title="添加数据">
        <Form :model="data" :rules="ruleValidate" ref="formCreate" label-position="top">
            <FormItem label="代码" prop="code">
                <Input v-model="data.code"></Input>
            </FormItem>
            <FormItem label="名称" prop="name">
                <Input v-model="data.name"></Input>
            </FormItem>
        </Form>
        <div slot="footer">
            <Button type="primary" icon="ios-add" @click="submit('formCreate')">提交</Button>
            <Button type="warning" icon="md-log-out" @click="defaultValue = false;">返回</Button>
        </div>

    </IDrawer>
</template>

<script>

    import IDrawer from "../../../../../components/layout/IDrawer";
    import IData from './data';
    import IDrawerMixins from "../../../../../mixins/iDrawerMixins";
    export default {
        name: "create",
        components: {IDrawerMixins, IDrawer},
        mixins: [IData, IDrawerMixins],
        data() {
            return {}
        },
        methods: {
            submit(data) {
                this.validate(data).then(() => {
                    this.loading = true;
                    this.$http.post(`system/dictionary/country`, this.data).then(() => {
                        this.defaultValue = false;
                    }).finally(() => {
                        this.loading = false;
                    });
                });
            }
        }
    }
</script>

<style scoped>

</style>